package com.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import java.io.Serializable;
@AllArgsConstructor
@NoArgsConstructor
@Data
//@PropertySource(value = "classpath:application.properties")
@Component
@ConfigurationProperties(prefix = "person")
@Validated
public class Person implements Serializable {
    /*jsr303校验，详见goodnotes中 搜索‘校验’*/
    //使用yaml文件
//    @Email(message = "邮箱格式错误！")
//    private String name;
//    @Max(value = 200,message = "年龄不能超过200")
    private int age;
    private String hobby;
    private Dog dog;
    /*
    使用properti文件,可以不使用@Value注解，跟yaml用法类似

    //@Value("${person.name}")
    private String name;
    //@Value("${person.age}")
    private int age;
  //  @Value("${person.hobby}")
    private String hobby;
   // @Value("${person.Dog}")
    private Dog dog;*/
}
